import request from '@/utils/request'
// 根据售货机获取运营人员列表
export const vendingMachine = (innerCode) => {
  return request({
    url: `/api/user-service/user/operatorList/${innerCode}`
  })
}
// 获取售货机货道详情(添加工单里需要)
export const addVending = (innerCode) => {
  return request({
    url: `/api/vm-service/channel/channelList/${innerCode}`
  })
}
// 补货详情
export const replenishmentDetails = (taskId) => {
  return request({
    url: `/api/task-service/taskDetails/${taskId}`
  })
}
// 获取补货预警值
export const alertValueFn = (alertValue) => {
  return request({
    url: `/api/task-service/task/supplyAlertValue`,
    alertValue
  })
}
// 设置自动补货工单阈值
export const thresholdValue = (data) => {
  return request({
    url: `/api/task-service/task/autoSupplyConfig`,
    method: 'POST',
    data

  })
}
// pageIndex	否		页码
// pageSize	否		每页数量
// status	否		售货机状态(0:未投放;1-运营;3-撤机)
// innerCode	否		售货机编号
// 搜索售货机(售货机列表)status售货机状态(0:未投放;1-运营;3-撤机)
export const searchMachine = ({ pageIndex, pageSize, status, innerCode }) => {
  return request({
    url: `/api/vm-service/vm/search`,
    params: {
      pageIndex, pageSize, status, innerCode
    }
  })
}
// 售货机类型详情
export const typeDetails = (typeId) => {
  return request({
    url: `/api/vm-service/vmType/${typeId}`
  })
}
// 售货机类型列表(搜索)
export const typeList = ({ pageIndex, pageSize, name }) => {
  return request({
    url: `/api/vm-service/vmType/search`,
    params: {
      pageIndex,
      pageSize,
      name
    }
  })
}
// 新增售货机
export const addVendingMachine = (data) => {
  return request({
    url: `/api/vm-service/vm`,
    method: 'POST',
    data
  })
}
// 查询售货机策略
export const tactics = (innerCode) => {
  return request({
    url: `/api/vm-service/policy/vmPolicy/${innerCode}`
  })
}
// 取消策略
// innerCode	售货机编号
// policyId		策略Id
export const cancelApi = (innerCode, policyId) => {
  return request({
    url: `/api/vm-service/vm/cancelPolicy/${innerCode}/${policyId}`,
    method: 'PUT'
  })
}
// id		售货机Id
// nodeId		点位Id
// 修改售货机点位
export const modifyingPoint = (id, nodeId) => {
  return request({
    url: `/api/vm-service/vm/cancelPolicy/${id}/${nodeId}`,
    method: 'PUT'
  })
}
// 获取商圈下销量前10的商品(补货推荐)
export const topTen = (businessId) => {
  return request({
    url: `/api/vm-service/sku/businessTop10/${businessId}`
  })
}
// 应用策略
// innerCodeList 售货机编号列表
// policyId 策略Id
export const applicationStrategy = (data) => {
  return request({
    url: `/api/vm-service/vm/applyPolicy`,
    method: 'PUT',
    data
  })
}
// 获取策略列表
export const tacticsList = () => {
  return request({
    url: `/api/vm-service/policy`
  })
}
// 新增售货机类型
export const AddTactics = (data) => {
  return request({
    url: `/api/vm-service/vmType`,
    method: 'POST',
    data
  })
}
// 售货机类型修改
export const modifyTactics = (typeId, data) => {
  return request({
    url: `/api/vm-service/vmType/${typeId}`,
    method: 'PUT',
    data
  })
}
// 售货机类型删除
export const delTactics = (typeId) => {
  return request({
    url: `/api/vm-service/vmType/${typeId}`,
    method: 'DELETE'
  })
}
